package cn.wen.eeayjoke.ui;

import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;

import butterknife.BindView;
import butterknife.OnClick;
import cn.wen.core.titlebar.DefTitleBar;
import cn.wen.core.ui.AppActivity;
import cn.wen.eeayjoke.R;

/**
 * 加载状态页面测试
 * 状态有：加载中、正常内容、网络请求出错、后台数据解析错误、空数据的页面其五种
 * 第个APP不一样，所有状态默认的页面需定制修改：在lib-core layout 里面.
 */

public class LoadingTestActivity extends AppActivity {
    @BindView(R.id.loading)
    Button mLoading;
    @BindView(R.id.content)
    Button mContent;
    @BindView(R.id.net_error)
    Button mNetError;
    @BindView(R.id.data_error)
    Button mDataError;
    @BindView(R.id.empty)
    Button mEmpty;
    @BindView(R.id.fl_content)
    FrameLayout mFlContent;

    @Override
    protected Object getContentLayout() {
        return R.layout.loading_test;
    }

    @Override
    protected void initTitle(DefTitleBar titleBar) {
        titleBar.setTitle("加载页面测试");
    }

    @Override
    protected Object getLoadingParentView() {
        return mFlContent;
    }

    @Override
    public void initNet() {
        mLoadingLayout.showLoading();
    }

    @OnClick({R.id.loading, R.id.content, R.id.net_error, R.id.data_error, R.id.empty})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.loading:
                mLoadingLayout.showLoading();
                break;
            case R.id.content:
                mLoadingLayout.showContent();
                break;
            case R.id.net_error:
                mLoadingLayout.showRetry();
                break;
            case R.id.data_error:
                mLoadingLayout.showDataError();
                break;
            case R.id.empty:
                mLoadingLayout.showEmpty();
                break;
        }
    }
}
